package com.orange.core.mapper.user;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.orange.core.pojo.entity.user.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

public interface UserMapper extends BaseMapper<User> {

    @Update("update user set credit = credit - #{credit} where id = #{userId} and credit >= #{credit}")
    boolean deductCredit(@Param("userId") int userId, @Param("credit") int credit);

    @Update("update user set credit = credit + #{credit} where id = #{userId}")
    boolean addCredit(@Param("userId") int userId, @Param("credit") int credit);
}
